import json
from pprint import pprint

# 读取
file_load = open('index.json', 'r', encoding='utf-8')
info = json.load(file_load)
pprint(info)
print(type(info))
print('----------------------------------------------------')
file_loads = open('index.json', 'r', encoding='utf-8')
info = json.loads(file_loads.read())
pprint(info)
print(type(info))
"""
结果：
{'config': {'lang': ['en'], 'min_search_length': 3},
 'docs': [{'title': 'Home'}]}
<class 'dict'>
----------------------------------------------------
{'config': {'lang': ['en'], 'min_search_length': 3},
 'docs': [{'title': 'Home'}]}
<class 'dict'>

----->
1.load中参数为fp对象，loads中参数为str对象
2.返回值都是dict类型
"""
# 写入
json_info = "{'config': {'lang': ['en'], 'min_search_length': 3},'docs': [{'title': 'Home'}]}"
file = open('1.json', 'w', encoding='utf-8')
json.dump(json_info, file)
